﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="importresult.aspx.cs" Inherits="UI.system.page.import.importresult" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="/system/js/jquery.min.js"></script>
    <script src="/system/layui/layui.js"></script>
    <script src="/system/js/common.js"></script>
    <script src="/system/js/md5.js"></script>
    <script src="/system/js/swfupload.js"></script>
    <link rel="stylesheet" href="/system/layui/css/layui.css">
    <link rel="stylesheet" href="/system/css/iframe.css">
</head>
<body>
    <div style="margin: 35px;">
	<form class="layui-form" style="padding-left:0px;">
       <%--<div class="layer-toolbar">
            <div class="layer-toolbar-left" style="color: blueviolet;">
               <%-- <a class="layui-btn layui-btn-small" onclick="xiazai();">下载模板</a>
               如果没有上传模板，请点击  <a href="Excel/上传数据模板.xlsx" target="_self">下载模板</a>
            </div>
            <div class="layer-toolbar-right">
            
            </div>
        </div>--%>
        <div class="layui-form-item" style="padding-top:30px;">
			<label class="layui-form-label">选择Excel：</label>
			<div class="layui-input-block" style="width:400px;">
                <div id="upload_products" class='upload_product' ext=""><div id="upload_product"></div></div> <div id="percent" class="percent" style="width:280px; height:36px; line-height:31px; float:left; padding-top:5px; font-size:12px; color:red; padding-left:10px;">(导入之前请确认数据格式是否正确)</div>
                <div></div>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"></label>
			<div class="layui-input-block" style="width:300px;">
				<input class="btn btn-primary radius" type="button" onclick="Begin()" value="&nbsp;开始导入&nbsp;" disabled="disabled" style="background:#cdcdcd; border:1px solid #cdcdcd;">
			</div>
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label"></label>
			<div class="layui-input-block" style="width:300px;">
				<div id="import_txt"></div>
			</div>
		</div>
	</form>
</div>
<script>
    function Begin() {
        $(".btn-primary").val("正在导入...");
        $("#import_txt").html("正在导入第<font style='color:red;'>1</font>页");
        $(".btn-primary").attr("disabled", "disabled").attr("style", "background:#cdcdcd; border:1px solid #cdcdcd;");
        Import(1);
    }
    function Import(pageindex) {
        var data = {};
        data.act = "Import_Mobile1";
        data.adminid = <%=adminid %>;
        data.ext = $("#upload_products").attr("ext");
        data.pageindex = pageindex;
        Ajax.Post("/tools/Admin.ashx", data, function (r) {
            var json = $.parseJSON(r);
            if (json.state) {
                if (json.data.pageindex != "0") {
                    $("#import_txt").html("正在导入第<font style='color:red;'>" + json.data.pageindex + "</font>页，共<font style='color:red;'>" + json.data.pagesize + "</font>页");
                    Import(json.data.pageindex);
                } else {
                    $(".btn-primary").removeAttr("disabled").removeAttr("style");

                    LayerBox.Success("导入成功", 1000, function () {
                        LayerBox.Close.ByAll();
                        var dataid = "<%=dataid %>";
                        //在这获取最外层页面   并且找到指定 class 的iframe框架
                        $(window.parent.document).find("." + dataid + "").contents().find("#reflesh").click();
                        window.parent.element.tabChange('demo', "" + dataid + "");
                        window.parent.element.tabDelete('demo', "daoru1");
                    });
                }
            } else {
                LayerBox.Error(json.msg);

                var dataid = "<%=dataid %>";
                //在这获取最外层页面   并且找到指定 class 的iframe框架

                $(window.parent.document).find("." + dataid + "").contents().find("#reflesh").click();
                window.parent.element.tabChange('demo', "" + dataid + "");
                window.parent.element.tabDelete('demo', "daoru1");
            }
        });
    }
    var upload = new Upload_File("upload_product", "*.xls;*.xlsx;*.csv");
    upload.swfu.handle = "upload_excel";

    function xiazai() {
        window.location.href = "Excel/上传数据模板.aspx";
    }
</script>
</body>
</html>
